
package com.ami.kvm.jviewer.soc;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.nio.ByteBuffer;

import com.ami.kvm.jviewer.common.ISOCApp;
import com.ami.kvm.jviewer.gui.JViewerApp;
import com.ami.kvm.jviewer.kvmpkts.IVTPPktHdr;
import com.ami.kvm.jviewer.soc.video.HardwareCursor;
import com.ami.kvm.jviewer.soc.video.VideoEngineConfigs;

public class SOCApp implements ISOCApp {
	public HardwareCursor HdrCur;
	public boolean m_firstTime = true;
	public int[][] m_currCursorFrame;
	public int[][] m_currCursorRect;
	public static int[][] m_prevCursorRect;
	public static boolean cursor_flag = false;

	public void SOC_Menu_ActionMethod(ActionEvent paramActionEvent) {
		String str = paramActionEvent.getActionCommand();

		SOCKVMclient localSOCKVMclient = (SOCKVMclient) JViewerApp.getInstance().getSockvmclient();
		VideoEngineConfigs localVideoEngineConfigs = localSOCKVMclient.getVideoEngineConfigs();

		if (str.equals("YUV_420")) {
			localVideoEngineConfigs.compression_mode = 0;
		} else if (str.equals("YUV_444")) {
			localVideoEngineConfigs.compression_mode = 1;
		} else if (str.equals("YUV_444_2_COLORS_VQ")) {
			localVideoEngineConfigs.compression_mode = 2;
		} else if (str.equals("YUV_444_4_COLORS_VQ")) {
			localVideoEngineConfigs.compression_mode = 3;
		}

		if (str.equals("DCT_Table_0")) {
			localVideoEngineConfigs.dct_quant_tbl_select = 0;
		} else if (str.equals("DCT_Table_1")) {
			localVideoEngineConfigs.dct_quant_tbl_select = 1;
		} else if (str.equals("DCT_Table_2")) {
			localVideoEngineConfigs.dct_quant_tbl_select = 2;
		} else if (str.equals("DCT_Table_3")) {
			localVideoEngineConfigs.dct_quant_tbl_select = 3;
		} else if (str.equals("DCT_Table_4")) {
			localVideoEngineConfigs.dct_quant_tbl_select = 4;
		} else if (str.equals("DCT_Table_5")) {
			localVideoEngineConfigs.dct_quant_tbl_select = 5;
		} else if (str.equals("DCT_Table_6")) {
			localVideoEngineConfigs.dct_quant_tbl_select = 6;
		} else if (str.equals("DCT_Table_7")) {
			localVideoEngineConfigs.dct_quant_tbl_select = 7;
		}

		IVTPPktHdr localIVTPPktHdr = new IVTPPktHdr((short) 4100, localVideoEngineConfigs.size(), (short) 0);
		JViewerApp.getInstance().getKVMClient().sendMessage(localIVTPPktHdr.array(), localIVTPPktHdr.size());
		JViewerApp.getInstance().getKVMClient().sendMessage(localVideoEngineConfigs.array(),
				localVideoEngineConfigs.size());
	}

	public void OnInvokeSocMenuShortCutFullscreen(KeyEvent paramKeyEvent) {
	}

	public void onHardwareCursor(ByteBuffer paramByteBuffer) {
		if (this.HdrCur == null) {
			this.HdrCur = new HardwareCursor(JViewerApp.getInstance().getVidClnt());
		}
		this.HdrCur.set(paramByteBuffer);
		this.HdrCur.drawCursor();
	}

	public int SOC_Session_validated() {
		return 0;
	}
}
